<?php

require '../com.swiss.mooh.dao.impl/ImageContentDaoImpl.php';
require '../com.swiss.mooh.service/ImageContentServiceImpl.php';

$dispatcher = new ImageContentDaoImpl();
$imageContentService = new ImageContentServiceImpl($dispatcher);

$output_dir = "../../assets/images/uploads/images/";

$descID = $_POST['descID'];

$listOfImageVO = $imageContentService->getImageByDescID($descID);
for ($i = 0; $i < $listOfImageVO->Size(); $i++) {
    $filePath = $output_dir . $listOfImageVO->GetObj($i)->getImageName();
    if (file_exists($filePath)) {
        unlink($filePath);
        $imageContentService->deleteImageContentByID($listOfImageVO->GetObj($i)->getImageName());
    }
}
echo 200;

